﻿#include "DATestNodeGraphicsItem.h"
#include <QPainter>
#include "DANodePalette.h"

DATestNodeGraphicsItem::DATestNodeGraphicsItem(DATestNode *n, QGraphicsItem *p) : DAAbstractNodeGraphicsItem(n, p)
{
    resetLinkPoint();
}

void DATestNodeGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    painter->save();
    QPen pen(DANodePalette::getGlobalEdgeColor());
    QRectF rec = boundingRect();

    pen.setWidth(1);
    if (isSelected()) {
        pen.setWidth(2);
        pen.setColor(pen.color().darker());
        rec.adjust(1, 1, -1, -1);
    }
    painter->setPen(pen);
    painter->fillRect(rec, DANodePalette::getGlobalBackgroundColor());
    painter->drawRect(rec);
    //绘制点
    paintLinkPoints(painter, option, widget);
    painter->restore();
}

QRectF DATestNodeGraphicsItem::boundingRect() const
{
    return (QRectF(0, 0, 50, 50));
}
